{extend name="$base" /}
{block name="resources"}
<link rel="stylesheet" type="text/css" href="ADMIN_CSS/member_list.css" />
<script type="text/javascript" src="__STATIC__/My97DatePicker/WdatePicker.js"></script>

{/block}
{block name="main"}
<div class="set-style">
	<dl>
		<dt><span class="required">*</span>买币数量:</dt>
		<dd>
			<input type="text" id="buy_coin_count" class="input-common">
			<p class="error">请输入买币数量</p>
			<p class="hint">设置买币数量</p>
		</dd>
	</dl>
	<dl>
		<dt><span class="required">*</span>送小型矿机:</dt>
		<dd>
			<input type="number" id="give_small" class="input-common">
			<p class="error">请输入数量</p>
			<p class="hint">设置数量</p>
		</dd>
	</dl>
	<dl>
		<dt><span class="required">*</span>送中型矿机:</dt>
		<dd>
			<input type="number" id="give_middle" class="input-common">
			<p class="error">请输入数量</p>
			<p class="hint">设置数量</p>
		</dd>
	</dl>
	<dl>
		<dt><span class="required">*</span>送大型矿机:</dt>
		<dd>
			<input type="number" id="give_large" class="input-common">
			<p class="error">请输入数量</p>
			<p class="hint">设置数量</p>
		</dd>
	</dl>
	<dl>
		<dt><span class="required">*</span>送超级矿机:</dt>
		<dd>
			<input type="number" id="give_super" class="input-common">
			<p class="error">请输入数量</p>
			<p class="hint">设置数量</p>
		</dd>
	</dl>
	<dl>
		<dt></dt>
		<dd>
			<button class="btn-common btn-big" onclick="addGift();">保存</button>
		</dd>
	</dl>
</div>
<script src="__STATIC__/js/ajax_file_upload.js" type="text/javascript"></script>
<script src="__STATIC__/js/file_upload.js" type="text/javascript"></script>
<script>	
     var flag = false;//防止重复提交
	//保存
	function addGift(){
		var buy_coin_count = $("#buy_coin_count").val();
        var give_small = $("#give_small").val();
        var give_middle = $("#give_middle").val();
        var give_large = $("#give_large").val();
        var give_super = $("#give_super").val();

        if(flag){
			return false;
		}
		flag = true;
		$.ajax({
			type : "post",
			url : "ADMIN_MAIN/mine/addCoinSend",
			data : {
				'buy_coin_count' : buy_coin_count,
				'give_small' : give_small,
                'give_middle' : give_middle,
				'give_large' : give_large,
                'give_super' : give_super
			},
			async : true,
			success : function(data) {
				//alert(JSON.stringify(data));
				if (data["code"] > 0) {
					showMessage('success', data["message"]);
                    setTimeout('parent.close_Layer();parent.location.reload()',2000);
				}else{
					showMessage('error', data["message"]);
				}	
				flag = false;
			}
		});
	}

     //图片上传
     function imgUpload(event) {
         var fileid = $(event).attr("id");
         var data = { 'file_path' : UPLOADCOMMON };
         var id = $(event).next().attr("id");
         uploadFile(fileid,data,function(res){
             if(res.code){
                 $("#"+id).val(res.data);
                 $("#text_" + id).val(res.data);
                 $("#preview_" + id).attr("data-src",__IMG(res.data));
                 showTip(res.message,"success");
             }else{
                 showTip(res.message,"error");
             }
         });
     }
</script>
{/block}